import request from '@/utils/request'
import config from './config'
import SM3 from 'sm3'

export function login(
  username,
  password,
  projectId,
  randomCode,
  randomCodeKey
) {
  return request({
    url: config.login,
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: {
      randomCode,
      randomCodeKey,
      userNo: username,
      password: SM3(password).toString(),
      projectId: projectId,
      sysType: 0
    }
  })
}

export function getSystemParams() {
  return request({
    url: config.getParams,
    method: 'post'
  })
}

export function getInfo(userNo) {
  return request({
    url: config.userInfo,
    method: 'get',
    params: {
      start: 1,
      limit: 1,
      q_userNo: userNo
    }
  })
}

export function logout(data) {
  return request({
    url: config.logout,
    method: 'post',
    data
  })
}
